<template>
	<view>
		<u-sticky bgColor="#fff">
			<u-tabs :list="list1" :current="currentIndex" @click="handleTabChange"></u-tabs>
		</u-sticky>

		<TabContent
			v-for="(item, index) in list1"
			v-if="currentIndex === index"
			:key="item.name"
			:tabId="currentIndex"
			:name="item.name" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list1: [
					{ name: '关注' },
					{ name: '推荐' },
					{ name: '电影' },
					{ name: '科技' },
					{ name: '音乐' },
					{ name: '美食' },
					{ name: '文化' },
					{ name: '财经' },
					{ name: '手工' }
				],
				currentIndex: 0 // 默认选中第一个标签
			};
		},
		methods: {
			handleTabChange(e) {
				console.log("当前索引:", e); // 调试输出
				this.currentIndex = e.index; // 更新当前选中的索引
			}
		}
	};
</script>

<style lang="scss">

</style>
